var LEAUI_MIND={};tinymce.PluginManager.add("leaui_mindmap",function(a,b){function c(){function c(){var c=a.settings.language,d=b+"/mindmap/index.html?i=1",e='<iframe id="leauiMindMapIfr" src="'+d+"?"+(new Date).getTime()+"&lang="+c+'" frameborder="0"></iframe>';return e}var d=a.dom,e=a.selection.getContent(),f=/<img.*?\/>/g,g=e.match(f),h=document.createElement("p");LEAUI_MIND={};for(var i in g){h.innerHTML=g[i];var j=h.firstChild;if(j&&"IMG"==j.nodeName){LEAUI_MIND.json=d.getAttrib(j,"data-mind-json");break}}var k=window.innerWidth-10,l=window.innerHeight-150;win=a.windowManager.open({title:"Mind Map",width:k,height:l,html:c(),buttons:[{text:"Cancel",onclick:function(){this.parent().parent().close()}},{text:"Insert",subtype:"primary",onclick:function(b){var c=this,d=document.getElementById("leauiMindMapIfr").contentWindow,e=d.km;e.exportData("png").then(function(b){var d=JSON.stringify(e.exportJson());d=d.replace(/'/g,"\u0416");var f='<img src="'+b+'" data-mce-src="-" data-mind-json=\''+d+"'>";a.insertContent(f),c.parent().parent().close()})}}]})}a.addButton("leaui_mindmap",{icon:"mind",tooltip:"Insert/edit mind map",onclick:c,stateSelector:"img[data-mind-json]"})});